/*
 *  ls_funcs.c
 *
 *  (C) 2011 Harry Wei
 */
#include <stdio.h>
#include <stdlib.h>

#include "sl.h"

int locate_seq(struct seq_list *l_seq, int *temp, int *number)
{
	if (l_seq->last < *number || *number < 0) {
		printf("Error happened!\n");
		return 1;
	} else {
		*temp = l_seq->elem[l_seq->last];
		return 0;
	}
}

int locate_val(struct seq_list *v_list, int *number, int *value)
{
	int i = 0;

	if (-1 == v_list->last) {
		printf("Vacant list!\n");
		return 1;
	}	
	do {
		if (*value == v_list->elem[i]) {
			*number = v_list->last;		/* A bug here */
			return 0;
		}
		i = i + 1;
	}while (v_list->last < i);
	printf("Your number is not in the list\n");
	return 1;
}
